Skip to content

feat: PositiveTemperature (closed for large commit size)#969

Closed
ichxorya wants to merge 19 commits intoleanprover-community:masterfrom
SEhumantics:feat/nghiabt/postemp
Closed

feat: PositiveTemperature (closed for large commit size)#969
ichxorya wants to merge 19 commits intoleanprover-community:masterfrom
SEhumantics:feat/nghiabt/postemp

Conversation

@ichxorya
Copy link
Contributor

@ichxorya ichxorya commented Mar 4, 2026

Ref: #958 #861 #860

In this PR I will construct relevant API for PositiveTemperature as discussed in #958

…he Thermodynamics module (with some extend to StatisticalMechanics since it depends on Thermodynamics)
…ine comments

TODO: from `tendsto_const_inv_mul_bound_pos` downwards
* Note: In `Calculus relating T and β`, the proofs are not really cleaned and humanized since it's kinda out of my league.
* Introduce `TemperatureScale` structure with detailed documentation.
* Implement conversion functions between kelvin and affine scales.
* Add lemmas to verify the identity of conversions.
* Define specific temperature scales: Celsius, Fahrenheit, and Rankine.
* Improve documentation for clarity and completeness.
* Refactor existing functions for better readability and maintainability.
* Added import for `TemperatureScales` in `PhysLean.lean`.
* Reformatted code for better readability in several lemmas across temperature-related files.
* Removed unnecessary blank lines to improve code clarity.
…itions (breaking change warning, currently only Basic.lean is compilable)
…lean (breaking change warning, currently only Basic.lean is compilable)
…ture and the Beta function; add Calculus.lean for PositiveTemperature (breaking change warning)
@ichxorya
Copy link
Contributor Author

ichxorya commented Mar 5, 2026

@jstoobysmith I would like to ask for direction from here. As of now, the code in Temperature is compilable. However, when it comes to the dependency at CanonicalEnsemble, I don't know what would actually work. Can you break the necessary rework for me (i.e. in terms of types, theorems, lemmas) so that I can follow it to finish this PR.

@hungle0503 would you also mind looking at this too?

Note that a vibe-coded solution is available at c853862 but I think it is wrong since it defines this

/-- Construct a `PositiveTemperature` from a real-valued inverse temperature,
defaulting to a junk value for non-positive inputs. Used for `derivWithin` helpers
that need a total function `ℝ → PositiveTemperature`. -/
noncomputable def ofβ_real (b : ℝ) : PositiveTemperature :=
  if h : 0 < b then ofβ ⟨b, h⟩ else ofβ ⟨1, one_pos⟩

Thus, it shouldn't be right due to that junk value when we define the total function (could a partial function work?)

@jstoobysmith
Copy link
Member

Hi @ichxorya, the problem with this PR is that it is still too big, which makes it very hard to review properly. In the end it will be quicker for everyone if we split this up into multiple PRs (aim for like 200-500 lines of changes each). I would start with just submitting the changes in:

PhysLean/Thermodynamics/Temperature/Basic.lean‎

@ichxorya
Copy link
Contributor Author

ichxorya commented Mar 5, 2026

Hi @ichxorya, the problem with this PR is that it is still too big, which makes it very hard to review properly. In the end it will be quicker for everyone if we split this up into multiple PRs (aim for like 200-500 lines of changes each). I would start with just submitting the changes in:

PhysLean/Thermodynamics/Temperature/Basic.lean‎

Thank you, I would follow that!

@ichxorya ichxorya closed this Mar 5, 2026
@ichxorya ichxorya changed the title feat: PositiveTemperature feat: PositiveTemperature (closed for large commit size) Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants